<?php $aPath = Yii::app()->theme->baseUrl . '/assets/'; ?>
<div class="sliderkit contacts-tabs">
    <div class="sliderkit-nav">
        <div class="sliderkit-nav-clip">
            <h3>Наши адреса</h3>
            <ul>
                <?php
                foreach (Yii::app()->params['regions'] as $regId => $region) {
                    $active = '';
                    if ($region['regionId'] == Yii::app()->session['userRegion']['id']) {
                        // $active = ' class="sliderkit-selected" ';
                    }
                    echo '<li' . $active . '><a href="#"><span data-id="' . $region['regionId'] . '">' . $region['regionTitle'] . '</span></a></li>';
                }
                ?>
            </ul>
        </div>
    </div>

    <div class="sliderkit-panels">
        <?php
        $metroStyles = [ 'bagrationovskaya', 'maryino',
            'voykovskaya', 'china-city',
            'prague', 'altufyevo',
            'novogireevo', 'teply-stan',
            'mitino',
        ];
        $contact_counter = 0;
        $found = false;
        foreach (Yii::app()->params['regions'] as $regId => $region) {
            $active = '';
            $style = ' style="display:none;" ';

            if ($region['regionId'] == Yii::app()->session['userRegion']['id']) {
                $active = ' sliderkit-panel-active ';
                $style = ' style="display:block;" ';
                $found = true;
            }
            if (!$found)
                $contact_counter++;

            echo '<div class="sliderkit-panel ' . $active . '" ' . $style . '>';
            echo '<h2 class="middle-title">' . $region['regionTitle'] . '</h2>'; // title
            echo '<div class="map"><script type="text/javascript" charset="utf-8" src="' . $region['map'] . '"></script></div>'; // map
            $sql = " SELECT * FROM {{pages}} WHERE \"pageType\"='contact' AND \"pageItemId\" = {$region['regionId']} AND \"pageActive\" = 1";
            $contacts = Yii::app()->db->createCommand($sql)->queryAll(true);
            if ($contacts) {
                echo '<ul class="contacts-list">';
                foreach ($contacts as $contact) {
                    $metroCss = unserialize(CHtml::decode($contact['pageLinkedServices']));
                    $phoneNew = isset($metroCss['phone']) ? $metroCss['phone'] : '';
                    $metroCss = !empty($metroCss['metroCss']) ? $metroCss['metroCss'] : $metroStyles[rand(0, sizeof($metroStyles) - 1)];

                    $ph = str_replace(array('+', ' ', '(', ')', '-'), array('', '', '', '', ''), $phoneNew);
                     $cl = '';
                    if ($ph == '84956468608') {
                        $cl = 'ya-phone';
                    }
                    if ($ph == '88123855903') {
                        $cl = 'ya-phone-spb';
                    }
                    if ($ph == '88432039688') {
                        $cl = 'ya-phone-kzn';
                    }
                    echo '<li class="contacts-list__item"><ul>';
                    echo '<li class="contacts-list__place">
							<div class="contacts-list__place__inner">
								<div class="contacts-icon  ' . $metroCss . ' ">
									<div class="contacts-icon__inner">&nbsp;</div>
								</div>
								<div class="contacts-list__description">
									<h3>
										<a href="/' . $contact['pageUrl'] . '">' . $contact['pageFullTitle'] . '</a>
									</h3>
									<p>' . $contact['pageContentShort'] . '</p>
                                                                            <p class="contact-phone">Звоните по телефону:
                                                                                <a href="tel:' . $ph . '">                                                                                    
                                                                                        <strong class="' . $cl . '">' . $phoneNew . '</strong>                                                                                    
                                                                                </a>
                                                                            </p> 
								</div>
							</div>    
						</li>';
                    echo '<li class="contacts-list__time">
								' . $contact['pageDescription'] . '
						</li>';
                    echo '<li class="contacts-list__more">
							<div class="contacts-list__more__inner">
								<span class="global-button green-bg">
									<a href="/' . $contact['pageUrl'] . '">Подробнее</a>
								</span>
							</div>    
						</li></ul></li>';
                }
                echo '</ul>';
            }
            echo '</div>';
        }
        Controller::$pageData['activeCity'] = $contact_counter;
        ?>
    </div>
</div>
<?php echo Controller::$pageData['pageContentFull']; ?>
<!-- Google Code for &#1082;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1099; Conversion Page -->
<script type="text/javascript">
/ <![CDATA[ /
var google_conversion_id = 956373091;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "VWhTCKOsnlsQ47CEyAM";
var google_remarketing_only = false;
/ ]]> /
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/956373091/?label=VWhTCKOsnlsQ47CEyAM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

